using AutoMapper;
using Pay.DTO;
using Pay.Data;
using Pay.IService;

namespace Pay.Service.AutoMapper {
	public class MemberAuthMapper : IStartupDto {
		private IMapperConfigurationExpression _cfg;
		public MemberAuthMapper(IMapperConfigurationExpression cfg) {
			_cfg = cfg;
		}
		public void Execute() {
			Create();
		}
		protected virtual void Create() {
			_cfg.CreateMap<member_dto, Member>()
				.ForMember(dest => dest.Id, src => src.MapFrom(c => c.id))
				.ForMember(dest => dest.Bank, src => src.MapFrom(c => c.bank))
				.ForMember(dest => dest.BankCard, src => src.MapFrom(c => c.bank_card))
				.ForMember(dest => dest.AccountName, src => src.MapFrom(c => c.account_name))
				.ForMember(dest => dest.Type, src => src.MapFrom(c => c.type))
				.ForMember(dest => dest.IdCard, src => src.MapFrom(c => c.id_card))
				.ForMember(dest => dest.AreaId, src => src.MapFrom(c => c.area_id))
				.ForMember(dest => dest.Address, src => src.MapFrom(c => c.address))
				.ForMember(dest => dest.CardPositive, src => src.MapFrom(c => c.card_positive))
				.ForMember(dest => dest.CardNegative, src => src.MapFrom(c => c.card_negative))
				.ForMember(dest => dest.CardHandheld, src => src.MapFrom(c => c.card_handheld))
				.ForMember(dest => dest.ShopHead, src => src.MapFrom(c => c.shop_head))
				.ForMember(dest => dest.ShopCheckout, src => src.MapFrom(c => c.shop_checkout))
				.ForMember(dest => dest.ShopSpace, src => src.MapFrom(c => c.shop_space))
				.ForMember(dest => dest.LegalPerson, src => src.MapFrom(c => c.legal_person))
				.ForMember(dest => dest.License, src => src.MapFrom(c => c.license))
				.ForMember(dest => dest.LicenseNo, src => src.MapFrom(c => c.license_no));
			_cfg.CreateMap<Member, member_dto>()
				.ForMember(dest => dest.id, src => src.MapFrom(c => c.Id))
				.ForMember(dest => dest.bank, src => src.MapFrom(c => c.Bank))
				.ForMember(dest => dest.bank_card, src => src.MapFrom(c => c.BankCard))
				.ForMember(dest => dest.account_name, src => src.MapFrom(c => c.AccountName))
				.ForMember(dest => dest.type, src => src.MapFrom(c => c.Type))
				.ForMember(dest => dest.id_card, src => src.MapFrom(c => c.IdCard))
				.ForMember(dest => dest.area_id, src => src.MapFrom(c => c.AreaId))
				.ForMember(dest => dest.address, src => src.MapFrom(c => c.Address))
				.ForMember(dest => dest.card_positive, src => src.MapFrom(c => c.CardPositive))
				.ForMember(dest => dest.card_negative, src => src.MapFrom(c => c.CardNegative))
				.ForMember(dest => dest.card_handheld, src => src.MapFrom(c => c.CardHandheld))
				.ForMember(dest => dest.shop_head, src => src.MapFrom(c => c.ShopHead))
				.ForMember(dest => dest.shop_checkout, src => src.MapFrom(c => c.ShopCheckout))
				.ForMember(dest => dest.shop_space, src => src.MapFrom(c => c.ShopSpace))
				.ForMember(dest => dest.legal_person, src => src.MapFrom(c => c.LegalPerson))
				.ForMember(dest => dest.license, src => src.MapFrom(c => c.License))
				.ForMember(dest => dest.license_no, src => src.MapFrom(c => c.LicenseNo));
			_cfg.CreateMap<member_dto, credentials_model>();
			_cfg.CreateMap<credentials_model, member_dto>();
		}
	}
}
